package com.olc.railing.busniess;

import com.olc.railing.utils.MyLog;
import com.olc.railing.utils.TimeUtils;
import com.softwinner.Gpio;

import java.util.Date;

public class LampControler {
    public static  void initGpio(){
        //1 输出 0 输入
        Gpio.setMulSel('O',1,1);//红灯1
        Gpio.setMulSel('O',2,1);//扣费灯
        Gpio.setMulSel('O',3,1);//红灯2
        Gpio.setMulSel('O',4,1);//红灯3

        Gpio.setMulSel('O',10,1);//补光灯
        Gpio.setMulSel('O',11,1);
        Gpio.setMulSel('O',12,1);
        Gpio.setMulSel('O',13,1);

        Gpio.writeGpio('O',1,1);//红灯1
        Gpio.writeGpio('O',2,1);//扣费灯
        Gpio.writeGpio('O',3,1);
        Gpio.writeGpio('O',4,1);

        Gpio.writeGpio('O',10,0);//补光灯
        Gpio.writeGpio('O',11,0);
        Gpio.writeGpio('O',12,0);
        Gpio.writeGpio('O',13,0);
        MyLog.d(MyLog.TAG,"initGpio.....");
    }

    public static void openRedLamp(){
        // MyLog.d(MyLog.TAG,"openRedLamp1");
        Gpio.writeGpio('O',2,0);
    }
    public static void closeRedLamp(){
        // int status = Gpio.readGpio('O',2);
        // MyLog.d(MyLog.TAG,"closeRedLamp1 status " +status);
        Gpio.writeGpio('O',2,1);
    }
    public static void openGreenLamp(){
        // MyLog.d(MyLog.TAG,"openGreenLamp");
        Gpio.writeGpio('O',4,0);
    }

    public static void closeGreenLamp(){
        // int status = Gpio.readGpio('O',4);
        // MyLog.d(MyLog.TAG,"closeGreenLamp status " +status);
        Gpio.writeGpio('O',4,1);
    }

    public static void openBuguangLamp(){
        if(!TimeUtils.isAround(6,18)){//晚18-早7
            MyLog.d(MyLog.TAG,"openBuguangLamp");
            Gpio.writeGpio('O',10,1);
        }
    }

    public static void closeBuguangLamp(){
        MyLog.d(MyLog.TAG,"closeBuguangLamp");
        Gpio.writeGpio('O',10,0);

    }
}
